<template>
  <div class="app-container">

    <div class="card-wrap flex-column justify-end card-padding">

      <div class="card-title-wrap">
        <span>基本信息</span>
        <span></span>
      </div>

      <el-descriptions title="">
        <el-descriptions-item label="供应商名称">{{ form.supplierName|filterNull }}</el-descriptions-item>
        <el-descriptions-item label="状态">
          <dict-tag
            :options="dict.type.supplier_status"
            :value="form.availableStatus"/>
        </el-descriptions-item>
        <el-descriptions-item label="统一社会信用代码">{{ form.taxpayerIdentityNumber|filterNull }}</el-descriptions-item>
        <el-descriptions-item label="纳税人资格">{{ form.taxpayerQualification|filterNull }}</el-descriptions-item>
        <el-descriptions-item label="联系人">
          {{ form.contact|filterNull }}
        </el-descriptions-item>
        <el-descriptions-item label="联系电话">{{ form.contactPhone|filterNull }}</el-descriptions-item>
        <el-descriptions-item label="法人(自然人)">{{ form.legalPerson|filterNull }}</el-descriptions-item>
        <el-descriptions-item label="邮编">{{ form.postalCode|filterNull }}</el-descriptions-item>
        <el-descriptions-item label="国家">{{ form.country|filterNull }}</el-descriptions-item>
        <el-descriptions-item label="城市">{{ form.cityName|filterNull }}</el-descriptions-item>
        <el-descriptions-item label="供应商联系地址">{{ form.contactAddr|filterNull }}</el-descriptions-item>
        <el-descriptions-item label="允许先付款后取发">{{0==form.invoiceExtractMethod?'是':1==form.invoiceExtractMethod?'否':'--'}}</el-descriptions-item>

        <el-descriptions-item label="供应商银行账户名称">{{ form.accountName|filterNull }}</el-descriptions-item>
        <el-descriptions-item label="开户银行名称">{{ form.bankName|filterNull }}</el-descriptions-item>
        <el-descriptions-item label="银行账户">{{ form.accountNumber|filterNull }}</el-descriptions-item>
        <el-descriptions-item label="账户性质">{{ form.accountNature|filterNull }}</el-descriptions-item>
        <el-descriptions-item label="币种">{{ form.currency|filterNull }}</el-descriptions-item>
        <el-descriptions-item label="公示系统超链接">{{ form.publicityHyperlink|filterNull }}</el-descriptions-item>
        <el-descriptions-item label="营业执照或公示截图">
          <div class="flex">
            <ImagePreview :src="getUrl(form.businessLicenseFrontImg)"></ImagePreview>
          </div>
        </el-descriptions-item>
        <el-descriptions-item label="备注">{{ form.memo|filterNull }}</el-descriptions-item>

        <el-descriptions-item label="附件">
          <div class="flex">
            <FilePreview :fileList="getUrl(form.annex)"></FilePreview>
          </div>
        </el-descriptions-item>

      </el-descriptions>

    </div>



<!--    <div class="card-wrap flex justify-end card-padding">-->
<!--      <el-button @click="cancel">取消</el-button>-->
<!--      <el-button :loading="buttonLoading" type="primary" @click="submitForm">保存</el-button>-->
<!--    </div>-->

  </div>
</template>

<script>


import {supplierBidDetail} from "@/api/memberManage/vendorList";
import FilePreview from "@/components/FilePreview/index.vue";

export default {
  components: {FilePreview},
  dicts: ['supplier_status'],
  data() {
    return {
      buttonLoading:false,
      form:{},
      activeName:'first'
    };
  },
  mounted() {
    if(this.$route.query){
      this.getOldData(this.$route.query.supplierId)
    }
  },
  methods: {
    getOldData(supplierId){
      supplierBidDetail(supplierId).then(res=>{
        this.form = res.data
      })
    },
    getUrl(ossid){
      ossid = String(ossid)
      if(ossid && ossid.indexOf(",") != -1){
        let split = ossid.split(",");

        let res = this.form.ossVos.filter(item=>{
          for (let splitElement of split) {
            if(item.ossId == splitElement){
              return item
            }
          }

        }).map(item=>{
          return item.url
        })
        console.log('aaa', res)
        return res

      }else {
        if(this.form.ossVos && this.form.ossVos.length){
          return this.form.ossVos.find(item=>{
            if(item.ossId == ossid){
              return item
            }
          })?.url
        }
      }
    },
  }
};
</script>


<style lang="scss" scoped>



</style>
